package com.itsu.mysql.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itsu.interfaces.entity.Settings;
import com.itsu.interfaces.service.SettingService;
import com.itsu.mysql.mappers.SettingMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class SettingServiceImpl implements SettingService {

    @Autowired
    SettingMapper settingMapper;

    @Override
    public Settings findSettingByUid(Long uid) {
        return settingMapper.selectOne(Wrappers.lambdaQuery(Settings.class).eq(Settings::getUserId, uid));
    }

    @Override
    public void update(Settings settings) {
        settingMapper.update(settings, Wrappers.lambdaUpdate(Settings.class).eq(Settings::getUserId, settings.getUserId()));
    }
}
